<template>
  <div class="main">
    <div v-if="optionsM==0">
    Code：<el-input v-model="code" placeholder="请输入Code"></el-input>
    
    Name：<el-input v-model="name" placeholder="请输入Name"></el-input>
    
    Sex：<el-input v-model="sex" placeholder="请输入sex"></el-input>
    
    Birthday：<el-date-picker v-model="birthday" type="date" placeholder="选择日期"></el-date-picker>
    
    Email：<el-input v-model="email" placeholder="请输入Email"></el-input>
    
    Phone：<el-input v-model="phone" placeholder="请输入Phone"></el-input>
    
    Password：<el-input v-model="password" placeholder="请输入Password" type="password"></el-input>
    
    Department：<el-input v-model="department" placeholder="请输入Department"></el-input>
    <el-row style="text-align:center">
      <el-button type="primary" @click.native="register()">注册</el-button><el-button icon="el-icon-arrow-left" @click.native="back"></el-button>
    </el-row>
    </div>
    <div v-else>
      Code：<el-input v-model="code" placeholder="请输入Code"></el-input>
    
      Name：<el-input v-model="name" placeholder="请输入Name"></el-input>
      
      Sex：<el-input v-model="sex" placeholder="请输入sex"></el-input>
      
      Phone：<el-input v-model="phone" placeholder="请输入Phone"></el-input>
      
      Password：<el-input v-model="password" placeholder="请输入Password" type="password"></el-input>
      
      Department：<el-input v-model="department" placeholder="请输入Department"></el-input>
      <el-row style="text-align:center">
        <el-button type="primary" @click.native="registerTeacher()">注册</el-button><el-button icon="el-icon-arrow-left" @click.native="back"></el-button>
      </el-row>
    </div>
   </div>
</template>

<script>
export default {
  props:['optionsM'],
  components: {
  },
  data() {
    return {
        code:'',
        name:'',
        sex:'',
        birthday:'',
        email:'',
        phone:'',
        password:'',
        department:'',
    };
  },
  computed: {
  },
  watch: {
  },
  created() {
  },
  methods: {
    register(){
        this.axios.get(`/SCS/student/insertStudent?code=${this.code}&name=${this.name}&sex=${this.sex}&birthday=${this.birthday}&email=${this.email}&phone=${this.phone}&password=${this.password}&department=${this.department}`
        ).then(
            response=>{
                console.log('1',response)
                this.$alert(`${response.data},请返回登录`, '提示', {
                    confirmButtonText: '确定',
                })
            },
            error=>{
                console.log('0',error)
            }
        )
    },
    registerTeacher(){
        this.axios.get(`/SCS/student/insertStudent?code=${this.code}&name=${this.name}&sex=${this.sex}&phone=${this.phone}&password=${this.password}&department=${this.department}`
        ).then(
            response=>{
                console.log('1',response)
                this.$alert(`${response.data},请返回登录`, '提示', {
                    confirmButtonText: '确定',
                })
            },
            error=>{
                console.log('0',error)
            }
        )
    },
    back(){
      this.$router.replace({
        name:'login'
      })
    }
  },
};
</script>
<style scoped lang="less">
.el-input{
    width: 300px;
    padding-bottom: 20px;
}
.main{
  text-align: left;
  border-radius: 20px;
	width: 300px;
	height: 350px;
	margin: auto;
	position: absolute;
	top: 0;
	left: 0;
	right: 0;

  }
  .el-button{
      width: 100px;
  }
</style>